<?php
echo isset($breadcrumb) ? $breadcrumb : "";
?>

<h3 class="title-popup">Form <?php echo $kode == "" ? "Tambah" : "Ubah"; ?> Menu</h3>

<form action="" method="post" onsubmit="return save();" enctype="multipart/form-data">
    <?php if ($error_message != ""): ?>
        <div class="BoxMessage Warning">Proses Gagal, <br /><?php echo $error_message; ?></div>
    <?php endif; ?>
    <fieldset class="fldInput">
        <dl>
            <dt>Menu Induk</dt>
            <dd><input readonly="readonly" class="read-only" type="text" name="menu_induk" id="menu_induk" value="<?php echo $parent_name; ?>" maxlength="50" size="40" /></dd>
            
            <dt class="mandatory">Nama Menu</dt>
            <dd><input type="text" name="menu" id="menu" value="<?php echo $row->menu; ?>" maxlength="50" size="40" /></dd>

            <dt class="mandatory">Link</dt>
            <dd><input type="text" name="link" id="link" value="<?php echo $row->link; ?>" maxlength="100" size="40" />&nbsp;e.g: {root}index.php/setting/deploy_php</dd>

            <dt>Urutan</dt>
            <dd>
                <select name="urutan_opt" style="width: 325px" onchange="update_urutan(this.value);">
                    <option value="after" <?php echo $row->urutan != $first && $row->urutan != $last? "selected='true'" : ""; ?>>After</option>
                    <option value="before">Before</option>
                    <option value="first" <?php echo $row->urutan == $first ? "selected='true'" : "" ?>>First</option>
                    <option value="last" <?php echo $row->urutan == $last ? "selected='true'" : "" ?>>Last</option>
                </select>
                &nbsp;
                <div id="daftar_div" style="<?php echo $row->urutan != $first && $row->urutan != $last? "display:inline" : "display:none";?>">
                    <?php echo $daftar_menu;?>
                </div>
            </dd>
            
            <dt>Is Active</dt>
            <dd>
                <select name="is_active" style="width: 325px">
                    <option value="1" <?php echo $row->is_active == 1 ? "selected='true'" : "" ?>>Ya</option>
                    <option value="0" <?php echo $row->is_active == 0 ? "selected='true'" : "" ?>>Tidak</option>
                </select>
            </dd>
            
            <dt>Use DB Replika?</dt>
            <dd>
                <select name="use_db_replika" style="width: 325px">
                    <option value="1" <?php echo $row->use_db_replika == 1 ? "selected='true'" : "" ?>>Ya</option>
                    <option value="0" <?php echo $row->use_db_replika == 0 ? "selected='true'" : "" ?>>Tidak</option>
                </select>
            </dd>

            <dt>&nbsp;</dt>
            <dd>
                <ul id="note">
                    <li>Field dengan remark harus diisi.</li>
                    <li>Gunakan tombol Cari untuk field dengan property read-only.</li>
                </ul>

            </dd>

        </dl>
    </fieldset>
    <div id="box-control-save">
        <input type="hidden" name="kode" id="kode" value="<?php echo $kode; ?>" />
        <input type="hidden" name="vMode" id="vMode" value="<?php echo $kode == "" ? "add" : "edit"; ?>" />
        <input type="submit" class="CommandButton" name="btnSimpan" value="Save"/>&nbsp;
        <input type="button" class="CommandButton" value="Cancel" onclick="javascript:closeGB_();"/>
    </div>
</form>
<script type="text/javascript">
    function closeGB_()
    {
        <?php echo CloseGB(true); ?>
    }

    function save()
    {
        var menu = document.getElementById("menu");
        var link = document.getElementById("link");

        if (trimValue(biller.value) == '')
        {
            alert('Nama Biller harus diisi!');
        }
        else
        {
            return true;
        }

        return false;
    }

    function trimValue(str)
    {
        var out = "";
        out = str.replace(/^\s+|\s+$/g, "");
        return out;
    }
    
    function update_urutan(value){
        var div = document.getElementById("daftar_div");
        
        if(value != "first" && value != "last")
            div.style.display = "inline";
        else
            div.style.display = "none";
    }
    
    
</script>
